﻿package tools;


import java.util.ArrayList;
import java.util.Collections;

public class ConversionDemo {
	public static void main(String[] args) {
		String strhex = new String("1AFF");
		// 将16进制数转换成10进制
		int intdecimal = Integer.parseInt(strhex, 16);
		System.out.println(intdecimal);
		// 将字符串转成数字
		String strdec = "12345";
		for (int i = 0; i < strdec.length(); i++) {
			int b = Integer.parseInt(String.valueOf(strdec.charAt(i)));
			// char直接给int，值是字符的ASCII码，
			// int b=strdec.charAt(i);
			System.out.print(" " + b);
		}
		System.out.println();
		// 字符串->list->反转list
		String strrev = "reverse";
		ArrayList<String> alrev = new ArrayList<String>();
		for (int i = 0; i < strrev.length(); i++) {
			alrev.add(String.valueOf(strrev.charAt(i)));
		}
		Collections.reverse(alrev);// 将list反转
		System.out.println(alrev);
		// Stringbuffer自带reverse方法
		StringBuffer strbrev = new StringBuffer("reverse");
		strbrev = strbrev.reverse();
		System.out.println(strbrev);
		
	}
}

